package com.ruoyi.system.controller.Evaluating;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.IndicatorSystem;
import com.ruoyi.system.domain.dto.StartEvaluationDto;
import com.ruoyi.system.domain.standard_relevant.StandardExcel;
import com.ruoyi.system.service.Evaluating.impl.EvaluationProcessService;
import com.ruoyi.system.service.IIndicatorService;
import com.ruoyi.system.service.IIndicatorSystemService;
import com.ruoyi.system.service.standard.IStandardExcelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;

import static com.ruoyi.common.core.domain.AjaxResult.success;
import static com.ruoyi.common.utils.PageUtils.startPage;

@RestController
public class EvaluationProcessController extends BaseController {
    @Autowired
    private EvaluationProcessService evaluationProcessService;

    @Autowired
    private IStandardExcelService standardExcelService;

    @Autowired
    private IIndicatorSystemService indicatorSystemService;


    @PostMapping("/processTopsis")
    public AjaxResult processTopsisByColumnAndRowNames(
                                                      @RequestBody StartEvaluationDto startEvaluationDto
                                                  ) throws IOException, ExecutionException, InterruptedException {
//        System.out.println(startEvaluationDto.getSystemId());
//        System.out.println(startEvaluationDto.getStandardCodes());
//        System.out.println(startEvaluationDto);
        evaluationProcessService.processTopsis(startEvaluationDto);
        return  AjaxResult.success("评估任务已提交，请稍后检查状态。");

    }
    /**
     * 查询指标体系
     */
    @GetMapping("/systemList")
    public TableDataInfo list(IndicatorSystem indicatorSystem)
    {
//        startPage();
        List<IndicatorSystem> list = indicatorSystemService.selectIndicatorSystemList(indicatorSystem);
        return getDataTable(list);
    }
    /**
     * 查询excel(标准三级指标)列表
     */
    @GetMapping("/standardList")
    public TableDataInfo list(StandardExcel standardExcel)
    {
//        startPage();
        List<StandardExcel> list = standardExcelService.selectStandardExcelList(standardExcel);
        return getDataTable(list);
    }
}
